﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>fly.simple.Tree 多选</title>
    <script src="../../../fly/fly-comment.js" type="text/javascript"></script>
    <script src="../../fly.simple-all-comment.js" type="text/javascript"></script>
    <link href="../skin/default/tree.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div>
        <div>
            fly.simple.Tree</div>
        保存Check状态和Select状态同步</div>
    <br />
    <div>
        单选：</div>
    <div id="treeDiv-single">
    </div>
    <div>
        同一级别单选：</div>
    <div id="treeDiv-singleByLevel">
    </div>
    <div>
        多选：</div>
    <div id="treeDiv-multi">
    </div>
    <script type="text/javascript">
        //单选
        var singleTree = new fly.simple.Tree({
            root: { icon: "5", text: "我的文档" },
            iconFormat: "imgs/{0}.gif",
            checkMode: fly.simple.checkMode.single,
            selectionMode: fly.simple.selectionMode.single,
            keepCheckAndSelectSync: true,
            async: {
                url: "data.txt?node={text}",
                method: "get"
            }
        });

        singleTree.load([
            { text: "音乐", icon: "4", leaf: false },
            { text: "电影", icon: "1", leaf: false },
            { text: "视频", icon: "2", leaf: false },
            { text: "图片", icon: "3" }
            ]);
        singleTree.renderTo("treeDiv-single")


        //同一级别单选
        var singleByLevelTree = new fly.simple.Tree({
            checkMode: fly.simple.checkMode.single,
            selectionMode: fly.simple.selectionMode.single,
            keepCheckAndSelectSync: true,
            root: { icon: "5", text: "我的文档" },
            iconFormat: "imgs/{0}.gif",
          
            async: {
                url: "data.txt?node={text}",
                method: "get"
            }
        });

        singleByLevelTree.load([
            { text: "音乐", icon: "4", leaf: false },
            { text: "电影", icon: "1", leaf: false },
            { text: "视频", icon: "2", leaf: false },
            { text: "图片", icon: "3" }
            ]);
        singleByLevelTree.renderTo("treeDiv-singleByLevel")


        //多选
        var multiTree = new fly.simple.Tree({
            checkMode: fly.simple.checkMode.multi,
            selectionMode: fly.simple.selectionMode.multi,
            checkCascade: {
                check: { parent: true, children: true },
                uncheck: { parent: true, children: true }
            },
            keepCheckAndSelectSync: true,
            root: { icon: "5", text: "我的文档" },
            iconFormat: "imgs/{0}.gif",
           
            async: {
                url: "data.txt?node={text}",
                method: "get"
            }
        });

        multiTree.load([
            { text: "音乐", icon: "4", leaf: false },
            { text: "电影", icon: "1", leaf: false },
            { text: "视频", icon: "2", leaf: false },
            { text: "图片", icon: "3" }
            ]);
        multiTree.renderTo("treeDiv-multi")
    </script>
</body>
</html>
